#!/usr/bin/env python
# -*- coding: utf-8 -*-

#集合覆盖问题

def greedy_algorithm():
    states_needed = set(['GD', 'BJ', 'SH', 'SZ', 'ZJ', 'HB', 'HN', 'XJ'])
    stations = {}
    stations['One'] = set(['SZ', 'ZJ', 'HB'])
    stations['Two'] = set(['BJ', 'SZ', 'GD'])
    stations['Three'] = set(['SH', 'ZJ', 'HN'])
    stations['Four'] = set(['ZJ', 'HB'])
    stations['Five'] = set(['HN', 'XJ'])
    final_stations = set()
    
    while states_needed:
        best_station = None
        states_covered = set()
        for station, states in stations.items():
            covered = states_needed & states
            if len(covered) > len(states_covered):
                best_station = station
                states_covered = covered
                
        states_needed -= states_covered
        final_stations.add(best_station)
        
    print(final_stations)


if __name__=='__main__':
    greedy_algorithm()
    
